package 冒泡排序;

import java.util.Arrays;

public class bubblesort {

    public static void swap(int[] array,int i,int j) {
        int tmp=array[i];
        array[i]=array[j];
        array[j]=tmp;
    }


    public static void bubbleSort(int[] array) {
        for(int i=0;i<array.length-1;i++){
            for(int j=0;j<array.length-1-i;j++){
                if(array[j] > array[j+1]){
                    swap(array,j,j+1);
                }
            }
        }
    }

    public static void main(String[] args) {
        int[] array={12,5,9,34,0,33,6,55};
        bubbleSort(array);
        System.out.println(Arrays.toString(array));

    }
}
